Package-level declarations
This package contains components that relate to the connected GoPro including methods to operate on it.
All objects here should be accessed as properties of a GoPro object returned from OgpSdk.getGoPro
Note that for all methods here, the return value will always be wrapped in a Result.
Commands
Commands are accessed in a CommandsContainer via GoPro.commands.
For example, to print all files from the media list:
gopro.commands.getMediaList().onSuccess {
it.media.forEach { fileList ->
fileList.files.forEach { file ->
println(file.filename)
}
}
}
Settings
Settings are accessed in a SettingsContainer via GoPro.settings. Each setting has several methods of interaction as defined in Setting.
For example...
To print the current resolution
gopro.settings.videoResolution.getValue().onSuccess { println(it.name) }
Content copied to clipboardTo print all currently available resolutions:
gopro.settings.videoResolution.getCapabilities().onSuccess {
it.forEach { resolution ->
println(resolution.name)
}
}Content copied to clipboardTo set the video resolution to a new value (assuming it is currently available):
check(gopro.settings.videoResolution.setValue(VideoResolution.NUM_4K).isSuccess)
Content copied to clipboardTo register for, collect, and print resolution value updates as they asynchronously occur:
gopro.settings.videoResolution.registerValueUpdates().onSuccess {
it.collect { resolution ->
println(resolution.name)
}
}Content copied to clipboardTo register for, collect, and print resolution capability updates as they asynchronously occur:
gopro.settings.videoResolution.registerCapabilityUpdates().onSuccess {
it.collect { resolutions ->
resolutions.forEach { resolution ->
println(resolution.name)
}
}
}Content copied to clipboard
Statuses
Statuses are accessed in a StatusesContainer via GoPro.statuses. Each status has several methods of interaction as defined in Status.
For example...
To get the current battery level:
gopro.statuses.internalBatteryPercentage.getValue().onSuccess { println(it) }
Content copied to clipboardTo register for, collect, and print battery value updates as they asynchronously occur:
gopro.statuses.internalBatteryPercentage.registerValueUpdate().onSuccess {
it.collect { batteryLevel ->
println(batteryLevel)
}
}Content copied to clipboard
Features
Features are higher layer abstractions of other API elements. They are accessed in a FeaturesContainer via GoPro.features
Here is a (naive) example of using the AccessPointFeature to connect the GoPro to a Wi-Fi access point:
with(gopro.features.accessPoint) {
// Get all available access opints and filter to find our target.
val entry = scanForAccessPoints().getOrThrow().first { it.ssid == "TARGET_SSID" }
// Start connecting to the access point..
connectAccessPoint(entry.ssid, "password").onSuccess {
// Wait to collect a finished element from the flow
it.first { state -> state.isFinished() }
}
}
Observation
Besides any of the flows returned from the various API elements above, there are several properties that can be observed as defined in IGpDescriptor.
For example...
To monitor disconnects:
gopro.disconnects.collect { network ->
println("The ${network.name} connection has dropped!")
}Content copied to clipboardTo wait until the camera is ready to perform an operation...
gopro.isReady.first { it }
Content copied to clipboardNote that the GoPro object itself already monitors this and will suspend any requested operations until the camera is ready. That is, the user does not need to track this manually.
Types
Scan and connect the camera to an Access Point
Camera-on-the-home-network (COHN) provisioning and querying
Wrapper to access operations exposed as methods.
Establish a Wi-Fi connection where the camera is an Access Point
Container used to access and exercise features
Top level interface to communicate with a connected GoPro.
Properties of a connectd GoPro
Container used to access and operate on settings.
Container used to access and operate on statuses.